package com.example.zhuyu.basemvp.utils;

import java.io.IOException;

import okhttp3.RequestBody;
import okio.Buffer;

public class StreamUtil {

    /**
     * 将body体转换为字符串
     */
    public static String bodyToString(RequestBody body) {
        try {
            Buffer buffer = new Buffer();
            if (body != null) {
                body.writeTo(buffer);
                return buffer.readUtf8();
            } else {
                return "";
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
